<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>并非真正的常量(实例3)</title>
</head>

<body>
    <h2>JavaScript const</h2>

    <p>以下实例修改常量数组:</p>

    <p id="demo"></p>
    <script>
        // 创建常量数组
        const cars = ["Saab", "Volvo", "BMW"];

        // 修改元素
        cars[0] = "Toyota";

        // 添加元素
        cars.push("Audi");

        // 显示数组
        document.getElementById("demo").innerHTML = cars;
    </script>
</body>

</html>